<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // split 把字符串转换为 数组 和 join() 相反
        // const str = 'pink,red'
        // const arr = str.split(',')
        // console.log(arr);
        // const str1 = '2023-3-4'
        // const arr1 = str1.split('-')
        // console.log(arr1);


        //2.字符串的截取 substring(开始的索引[, 结束的索引])
        //2.1如果省略 结束的索引号， 默认取到最后
        //2.2结束的索引号不包含想要截取的部分
        // const str = 'efgthkl'
        // console.log(str.substring(5,7));


        //3.startWith() 判断是不是以某个字符开头
        // const str = "To be, or not to be, that is the question"
        // console.log(str.startsWith("To be"));
        // console.log(str.startsWith("not to be"));
        // console.log(str.startsWith("not to be", 10));

        //4.includes() 判断一个字符串中是否包含另一个字符串
        const str = "To be, or not to be, that is the question"
        console.log(str.includes("To be"));
        console.log(str.includes("question"));

    </script>
</body>
</html>